using System;
using System.Runtime.InteropServices;
using System.Text;

namespace Catastrophe.Common.WindowsApi
{
	public class ProcessComm
	{
		private const int WmChar = 258;

		private const int GwlHwndparent = -8;

		private const byte WsExToolwindow = 128;

		private const byte WmGettext = 13;

		private const byte WmGettextlength = 14;

		private const int GWL_STYLE = -16;

		private const int WS_CHILD = 1073741824;

		[DllImport("user32.dll")]
		private static extern int GetClassName(IntPtr handle, [Out] StringBuilder className, int maxCount);

		[DllImport("user32.dll")]
		private static extern int SendMessage(IntPtr handle, int wMsg, int wParam, int lParam);

		[DllImport("user32.dll")]
		private static extern int SendMessage(IntPtr handle, int wMsg, int wParam, StringBuilder lParam);

		[DllImport("user32.dll")]
		public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

		[DllImport("User32.dll")]
		public static extern bool ShowWindow(IntPtr hWnd, int type);

		[DllImport("user32.dll")]
		public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

		public static int HideInTaskBar(IntPtr hWnd)
		{
			return ProcessComm.SetWindowLong(hWnd, -8, 128);
		}

		[DllImport("user32.dll", SetLastError = true)]
		public static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

		[DllImport("user32.dll", SetLastError = true)]
		public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

		[DllImport("user32.dll", SetLastError = true)]
		public static extern long SetWindowPos(IntPtr hwnd, long hWndInsertAfter, long x, long y, long cx, long cy, long wFlags);

		[DllImport("user32.dll", SetLastError = true)]
		public static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);

		[DllImport("user32.dll")]
		public static extern int GetWindowLong(IntPtr hwnd, int nIndex);
	}
}
